package com.hspedu.homework;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/1/29
 * @time 18:42
 */
public class Homework04 {
    public static void main(String[] args) {
        new CellPhone().testwork(new Calculator() {
            @Override
            public void work(double x, double y) {
                System.out.println(x + y);
            }
        },1,2);
    }
}

interface Calculator{
    void work(double x,double y);
}

class CellPhone{
    public void testwork(Calculator calculator,double x,double y){
        //动态绑定到运行类型的work方法
        calculator.work(x,y);
    }
}
